package com.ljk.study14swagger3.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * <p>
 * swagger配置
 * </p>
 *{@link EnableOpenApi 必选,启用swagger注解}
 * @author ljk
 * @date 2021/4/17 23:52
 */
@EnableOpenApi
@Configuration
public class SwaggerConfig {
    @Value("${swagger.enable}")
    private boolean swaggerEnable;
    /**
     * <p>
     * (可选)自定义首页属性 Docket配置,
     * (注意)Docket的enable方法是控制swagger开关的true为开,false为关
     * </p>
     * {@link Bean 将该方法注册为bean}
	 * @return Docket
     * @author ljk
     * @date 2021/4/17 23:56
     */
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(new ApiInfoBuilder()
                        .contact(new Contact("作者ljk","https://www.baidu.com/","leng-mail@qq.com"))
                        .title("Swagger3的接口文档by ljk")
                        .description("更多请咨询服务开发者ljk")
                        .version("1.0")
                        .build())
                .enable(swaggerEnable);
    }
}
